package com.w2cx.selenium.operate;

import com.w2cx.selenium.base.DriverBase;
import com.w2cx.selenium.page.ConfigOperatePositionPage;
import org.openqa.selenium.WebElement;

import java.io.IOException;

public class ConfigOperatePositionOperate {

    DriverBase driver;
    ConfigOperatePositionPage copp;

    public ConfigOperatePositionOperate(DriverBase driver){
        this.driver = driver;
        copp = new ConfigOperatePositionPage(driver);
    }

    //点击运营管理
    public void clickOperateManageMenu(){
        copp.click(copp.getOperateManageMenu());
    }

    //点击配置运营位
    public void clickConfigOperatePositionMenu(){
        copp.click(copp.getConfigOperatePositionMenu());
    }

    //点击添加按钮
    public void clickAddBtn(){
        copp.click(copp.getAddBtn());
    }

    //输入运营位名称
    public void inputOperatePosiName(String operaPosiName){
        copp.sendKeys(copp.getOperateNameInput(),operaPosiName);
    }

    //输入运营位标识
    public void inputOperatePosiSign(String sign){
        copp.sendKeys(copp.getOperateSignInput(),sign);
    }


    //点击运营位图片
    public void clickOperatePosiImgBtn(){
        copp.click(copp.getAddOperateImgBtn());
    }

    //上传图片
    public void execUpImgScript(){
        //调用exe
        Runtime exe = Runtime.getRuntime();
        //获取当前工程所在目录
        String path = System.getProperty("user.dir");
        //获取脚本
        String exeScript = path+"\\"+"exe"+"\\"+"upOperatePositionImg.exe";
        //执行脚本
        try {
            exe.exec(exeScript);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }


    //点击运营位类别下拉框
    public void clickOperateCateDownList(){
        copp.click(copp.getOperateCateDownList());
    }

    //选择类别
    public void selectOperateCategory(){
        copp.click(copp.getOperateCateSelect());
    }

    //选择所属页面
    public void selectBelongToPage(){
        copp.click(copp.belongToPageSelect());
    }

    //输入推荐数量
    public void inputRecommondNum(String num){
        copp.sendKeys(copp.getRecommondNumInput(),num);
    }


    //点击确定
    public void clickConfirmBtn(){
        copp.click(copp.getConfirmBtn());
    }


    //获取第一条
    public WebElement getFirstOperaPosition(){
       return copp.getFirstOperaPosition();
    }

    //点击删除
    public void clickFirstDelBtn(){
        copp.click(copp.getFirstOperaPosiDelBtn());
    }

    //点击确定
    public void clickDelConfirmBtn(){
        copp.click(copp.getDelConfirmBtn());
    }


}
